package leetcode11_20;

import org.junit.Test;

/**
 * @author shhjiang_001
 * @create 2020-03-09 15:43
 */
public class Solution12 {
    public String intToRoman(int num) {
        int[] valus = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
        String[] chars =new String[]{"M","CM","D","CD","C","XC","L","XL","X", "IX","V","IV","I"};
        StringBuilder res = new StringBuilder();
        for (int i = 0;i<valus.length;i++){
            while (num>=valus[i]){
                num = num - valus[i];
                res.append(chars[i]);
            }
        }
        return res.toString();
    }
    @Test
    public void test(){
        Solution12 solution12 = new Solution12();
        String s = solution12.intToRoman(3);
        System.out.println(s);
    }
}
